import { createRouter, createWebHistory, createWebHashHistory } from 'vue-router'

import Home from '@/pages/Home.vue'
import About from '@/pages/About.vue'
import News from '@/pages/News.vue'
import Detail from '@/pages/Detail.vue'

export const router = createRouter({
    history:createWebHistory(),//history模式和hash模式

    routes:[
        {
            //路由的重定向
            path:'/',
            // redirect:'/about'   //字符串写法
            // redirect:{path:'/about'} // 对象写法
            redirect:{name:'abouts'} //命名路由-对象写法
        },
        {
            path:'/home',
            //命名路由
            name:'homes',
            component:Home
        },
        {
            path:'/about',
            name:'abouts',
            components:{ab:About}
        },
        {
            path:'/news',
            name:'news',
            component:News,
            //子路由组件
            children:[{
                name:'detail',
                path:'detail',//此处不需要写/
                component:Detail
            }]
        }
    ]
})